The following configurations will get you setup to start browsing to the Temp-Rx website from your localhost. Go down through each section in the order presented below to set up your system.
SQL Server Express Database Permissions
In order for the Temp-Rx website to modify the your SQL Server Express database, you need to give yourself administrative rights on the database server and allow "NT AUTHORITY\NETWORK SERVICE" to connect to the database server as well. To accomplish these two tasks, follow the instructions below:
Add Admin Rights for Yourself
- Stop the SQL Server Express instance service (usually named: "SQL Server (SQLEXPRESS)") from Windows Services or SQL Server Configuration Manager.
- Open a Command window (as Admin) and run single-user mode as local admin with this command:
- Open a second Command window (as Admin)
- Open sqlcmd:
- Now add the "sysadmin" user in the second Command window (domain = your computer name, user = your Windows login username):
- In the first Command window, "Ctrl+C" the single-user mode to kill SQL Server Express instance service. Now restart SQL Server Express instance service from Windows Services or SQL Server Configuration Manager the normal way.
- Log into your SQL Express database server (".\SQLEXPRESS") using SQL Management Studio and Windows Authentication and the user you created should be listed under Logins with the credential of "sysadmin".
Source:
http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/76fc84f9-437c-4e71-ba3d-3c9ae794a7c4
Add a User Login to the Database Server - "NT AUTHORITY\NETWORK SERVICE"
- Log into your SQL Express database server (e.g.: ".\SQLEXPRESS") using SQL Management Studio and Windows Authentication.
- In the "Object Explorer" panel navigate to the following under your SQL Express database server: Security > Logins.
- Right click on the "Logins" folder and select "New Login...".
- Under the "General" page, in the "Login name" textbox, type "NT AUTHORITY\NETWORK SERVICE" or search for "NETWORK SERVICE" on your local computer.
- Under "User Mapping" do the following (NOTE: The TempRxTest and ASPNETDB databases must already be created!):
- In the "Users mapped to this login" table, check the "Map" checkbox next to "TempRxTest" database and type or search for "dbo" in the "Default Schema" column in the "TempRxTest" database row.
- With the "TempRxTest" row highlighted in the "Users mapped to this login" table, check the boxes "public" and "db_owner" in the "Database role membership for: TempRxTest" table. (NOTE: At this point, I don't know if these permissions are what we should go with.)
- Repeat steps 1 and 2 for the ASPNETDB. (NOTE: If you do not have the ASPNETDB database created in your database server, follow the instructions for "Adding Authorization Database to the TempRxMVC Project" first.)
- Click "OK" to save all the changes and verify no errors occur.
Setup the Temp-Rx Visual Studio Project to Use Localhost
- Open Visual Studio as Admin and open the "TempRxMVC" solution.
- Right click on the "TempRxMVC" project and select "Properties"
- Navigate to the "Web" tab, scroll down to the "Servers" section, and complete the following steps:
- Select the "Use Local IIS Web server" radio button and type a "Project URL" beginning with "http://localhost/[Application Name]" and filling in "[Application Name]" with whatever you want (e.g.: "http://localhost/TempRx").
- Click the "Create Virtual Directory" button.
- Build the solution to save the changes.
Setup the Temp-Rx Application in IIS to Use the Network Service Identity
- Open Windows Start Menu and open the "Internet Information Services (IIS) Manager" application under "Administrative Tools".
- In the "Connections" panel, expand your computer in the tree and right click "Application Pools" and select "Add Application Pool...".
- In the "Add Application Pool" dialog, fill out the following:
- Name: Can be anything you want it to be. I called it: "ASP.NET v4.0 - SQL Server Workaround".
- .NET Framework version: ".NET Framework v4.0.x"
- Managed pipeline mode: "Integrated"
- Start application pool immediately: [checked]
- Click "OK" to save the changes.
- When the newly created Application Pool appears in the "Application Pools" table, highlight it and under the "Actions" pane, select "Advanced Settings".
- In the "Advanced Settings" dialog box make the following selections:
- "(General)" section: "Enable 32-Bit Applications" = "True"
- "Process Model" section: "Identity" = "Network Service"
- Click the "OK" button to save the changes.
- Under the "Connections" panel of the "Internet Information Services (IIS) Manager" application, expand your computer and expand the following: "Sites" > "Default Web Site".
- Right click on your Temp-Rx application you created and select: "Manage Application" > "Advanced Settings...".
- Under the "(General)" section, for "Application Pool" select the Application Pool you just created.
- Click the "OK" button to save the changes.
Coding Changes in the Temp-Rx Website when Using Localhost
Some links and URL paths break when you switch the Temp-Rx website to use Localhost. Below are some coding corrections I have made to fix the problem:
Anchors/Hyperlinks Tags
<a title="Temp-Rx Home" href='@Url.Action("Index", "Home")'>TEMP-RX</a>
@*Create an anchor tag from an action*@
@Html.ActionLink("Home", "Index", "Home")
<a href='@string.Format("{0}?t=tab_btn_jobopenings", Url.Action("Index", "Pharmacy"))' title="For Pharmacies">For Pharmacies</a>
Image Tags
<img id="imgSocIcons" src='@Url.Content("~/Content/images/icons/social-icons.png")' alt="Social Icons" title="Socialize" style="cursor: pointer;" />
Link and Script Tags
<link href="@Url.Content("~/Content/TempRxMain.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>
Conclusion
After going through each of the sections above in order, you should be set up to navigate to the Temp-Rx website on your Localhost! To test to see if it worked follow these steps:
- Open your favorite Internet browser.
- Type the URL you setup for your Localhost in step 3.1 of the "Setup the Temp-Rx Visual Studio Project to Use Localhost" section above. If you set up your Temp-Rx website application like I did, you need only type and navigate to "http://localhost/TempRx" in the URL.
- If you configured the Temp-Rx website application and IIS correctly, the Temp-Rx website will display.
Troubleshooting
The following section is one error I came across while setting up Localhost for Temp-Rx on my machine.
SQL Server Configuration Manager - WMI Error (0x80041010)

If you get this error when you try to open "SQL Server Configuration Manager" the steps below should get you back up and running again. There are plenty of search results on Google as to why this error appears. For the purposes of this guide, I won't explain, I will just get to the solution:
- Open a Command window (as Admin) and type and execute the following (NOTE: This step did not work for me because the application couldn't find the command "/clearadap", but in some cases it will work.):
- Then type and execute the following:
- Next, change the directory (NOTE: You may have to change the "100" directory to whatever version of SQL Server you are using. I was using Microsoft SQL Server 2008 R2):
- Lastly, type and execute the following (NOTE: Again, you may have to change the "100" directory to whatever version of SQL Server you are using. I was using Microsoft SQL Server 2008 R2): mofcomp "C:\Program Files (x86)\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"
User Role Not Found Error
If your run across this error, please go to the "MsSQL to MySQL" wiki and follow the instructions for
"Adding Authorization Database to the TempRxMVC Project".
empRxMain
ASPNETDB